home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / testdate.pas < prev    next >
Pascal/Delphi Source File  |  1989-07-17  |  1KB  |  34 lines

  1. { This program to demonstrate the uses of the Dates unit was written by
  2.   John Roncalio, Blue Ribbon Software, Abbotsford, B.C., Canada, V2S 4V6}
  3.  
  4. PROGRAM TestDate;
  5. USES crt,dates;
  6. VAR
  7.  AllOK:BOOLEAN;
  8.  DS1,
  9.  DS2  : DateString;
  10.  Dt1,
  11.  Dt2  : Date;
  12.  Age  : WORD;
  13.  
  14. BEGIN
  15.  ClrScr; AllOK:=False;
  16.  Dt2:=SysDate;
  17.  WRITELN('Today is ',DayName[DayOfWeek(Dt2)],'. The date is ',DateToDateString(Dt2));
  18.  REPEAT
  19.   WRITE('Enter Birth Day as MoDyYear:  '); READLN(Ds1);
  20.   Dt1:=DateStringToDate(Ds1);
  21.   IF Dt1<>BadDate THEN AllOK:=True ELSE WRITELN('You entered an invalid date. Please try again.');
  22.  UNTIL AllOK;
  23.  WRITELN('That was a ',DayName[DayOfWeek(Dt1)]);
  24.  Age:=Trunc((Dt2-Dt1) / 365.25);
  25.  WRITE('You were ',Age,' years old ');
  26.  WRITELN((Dt2-Dt1)-Trunc(Age*365.25),' days ago.'); WRITELN;
  27.  WRITE('Enter some number of days hence: '); READLN(Dt1);
  28.  Ds1:=DateToDateString(Dt1+Dt2);
  29.  WRITELN('The date that is ',Dt1,' days from now is ',
  30.           COPY(Ds1,1,2)+'/'+COPY(Ds1,3,2)+'/'+COPY(Ds1,5,4));
  31.  WRITELN('That will be a ',DayName[DayOfWeek(Dt1+Dt2)]); WRITELN;
  32.  WRITELN('These date routines are only usefull until ',DateToDateString(3652499));
  33.  WRITELN('Sorry.');
  34. END.